package com.xjy.headfirst.迭代器;

/**
 * decription:
 *
 * @author 辛纪元
 * @since 2022-07-15
 */

public class Waitress {

    PancakeHouseMenu pancakeHouseMenu;

    DinerMenu dinerMenu;

    public Waitress(PancakeHouseMenu pancakeHouseMenu, DinerMenu dinerMenu) {
        this.pancakeHouseMenu = pancakeHouseMenu;
        this.dinerMenu = dinerMenu;
    }

    public void printMenu() {
        Iterator iterator = pancakeHouseMenu.createIterator();
        Iterator iterator1 = dinerMenu.createIterator();
        System.out.println("MENU\n-----\nBREAKFAST");
        printMenu(iterator);
        System.out.println("LUNCH MENU \n");
        printMenu(iterator1);
    }

    private void printMenu(Iterator iterator) {
        while (iterator.hasNext()) {
            MenuItem next = (MenuItem) iterator.next();
            System.out.println(next.getName() + ",    " + next.getPrice() + ",    " + next.getDescription());
        }
    }

}
